package org.jsola.hr.helper;

import org.jsola.common.SafeKit;
import org.jsola.hr.dto.EmpInfoXcxShowAddDTO;
import org.jsola.hr.dto.EmpInfoXcxShowUpdateDTO;
import org.jsola.hr.entity.EmpInfoXcxShowDO;
import org.jsola.hr.query.EmpInfoXcxShowQuery;
import org.jsola.hr.service.IEmpInfoXcxShowService;
import org.jsola.hr.vo.EmpInfoXcxShowVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

import static org.jsola.hr.core.AbstractTest.SITE_ID;



/**
 * 员工小程序展示项
 *
 * @author zhr
 */
@Component
public class EmpInfoXcxShowTestHelper extends BaseTestHelper {
    
    @Autowired
    private IEmpInfoXcxShowService empInfoXcxShowService;

    /**
     * 生成add测试数据
     * @return EmpInfoXcxShowAddDTO
     */
    public EmpInfoXcxShowAddDTO getEmpInfoXcxShowAddDTO(){
        EmpInfoXcxShowAddDTO empInfoXcxShowAddDTO = new EmpInfoXcxShowAddDTO();
        empInfoXcxShowAddDTO.setModuleName(getRandomValue("varchar",50));
        empInfoXcxShowAddDTO.setModuleCode(getRandomValue("varchar",30));
        empInfoXcxShowAddDTO.setIsShow(SafeKit.getBoolean(getRandomValue("tinyint",1)));
        return empInfoXcxShowAddDTO;
    }


    /**
     * 生成update测试数据
     * @return EmpInfoXcxShowUpdateDTO
     */
    public EmpInfoXcxShowUpdateDTO getEmpInfoXcxShowUpdateDTO(EmpInfoXcxShowVO empInfoXcxShowVO){
        return empInfoXcxShowService.selectDOById(empInfoXcxShowVO.getId(), SITE_ID).to(EmpInfoXcxShowUpdateDTO.class);
    }

    /**
     * 生成查询数据
     * @return EmpInfoXcxShowQuery
     */
    public EmpInfoXcxShowQuery getEmpInfoXcxShowQuery() {
        EmpInfoXcxShowQuery empInfoXcxShowQuery = new EmpInfoXcxShowQuery();
        List<EmpInfoXcxShowDO> empInfoXcxShowDOList = empInfoXcxShowService.list(new EmpInfoXcxShowDO(),SITE_ID);
        if (!CollectionUtils.isEmpty(empInfoXcxShowDOList)) {
            EmpInfoXcxShowDO empInfoXcxShowDO = empInfoXcxShowDOList.get(0);
            empInfoXcxShowQuery = empInfoXcxShowDO.to(EmpInfoXcxShowQuery.class);
        }
        return empInfoXcxShowQuery;
    }

    /**
     * 保存示例
     * @return EmpInfoXcxShowVO
     */
    public EmpInfoXcxShowVO saveEmpInfoXcxShowExample(){
        EmpInfoXcxShowAddDTO addDTO = this.getEmpInfoXcxShowAddDTO();
        EmpInfoXcxShowVO empInfoXcxShowVO = empInfoXcxShowService.save(addDTO,buildTokenUser());
        return empInfoXcxShowVO;
    }


}

